/*
 * @Author: szx
 * @Date: 2021-12-06 15:01:23
 * @LastEditTime: 2021-12-06 15:11:06
 * @Description:
 * @FilePath: \leetcode\400-499\454\454.js
 */
/**
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @param {number[]} nums3
 * @param {number[]} nums4
 * @return {number}
 */
var fourSumCount = function (nums1, nums2, nums3, nums4) {
    const map = new Map();
    for (let i of nums1) {
        for (let j of nums2) {
            map.set(i + j, (map.get(i + j) || 0) + 1);
        }
    }
    let cnt = 0;
    console.log(map);
    for (let i of nums3) {
        for (let j of nums4) {
            if (map.has(-i - j)) {
                cnt += map.get(-i - j);
            }
        }
    }
    return cnt;
};
console.log(fourSumCount([-1, -1], [-1, 1], [-1, 1], [1, -1]));
